package cn.org.bjca.seal.esspdf.client.test;

import cn.org.bjca.anysign.client.security.SecurityEngineDeal;
import org.junit.Before;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Properties;

/***************************************************************************
 * <pre>
 *     基础测试用例
 * </pre>
 * @文件名称: AnyWriteBaseTest
 * @包路径： cn.org.bjca.seal.esspdf.client.test
 * @版权所有： 北京数字认证股份有限公司 (C) 2017
 *
 * @类描述:
 * @版本: V2.0
 * @创建人： 费玥
 * @创建时间： 20:22
 *
 ***************************************************************************/
public class AnyWriteBaseTest {

	private String resourcesPath;

	String testEncDataPath;

	String testHtmlFilePath;

	String testPdfFilePath;

	String testXMLFilePath;

	String testImageFilePath;

	String outPdfsFilePath;

	String testSignedPdfFilePath;


	SecurityEngineDeal sed;

	private static Properties errorCodeProperties = new Properties();

	static {
		try {
			errorCodeProperties.load(AnyWriteBaseTest.class.getClassLoader().getResourceAsStream("PDFClientErrorCode.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * <p>状态码转换为状态信息</p>
	 * @Description:
	 * @param errorCode 状态码
	 * @return:java.lang.String
	 * @throws:
	 */
	protected String errorCode2Info(int errorCode) {
		return errorCodeProperties.getProperty(String.valueOf(errorCode));
	}

	@Before
	public void initPathParams() throws UnsupportedEncodingException {
		resourcesPath = URLDecoder.decode(this.getClass().getClassLoader().getResource("").getPath(), "UTF-8");
		testEncDataPath = resourcesPath + "encdata" + File.separator;
		testHtmlFilePath = resourcesPath + "html" + File.separator + "test.html";
		testPdfFilePath = resourcesPath + "pdf" + File.separator + "test.pdf";
		testXMLFilePath = resourcesPath + "xml" + File.separator + "test.xml";
		testImageFilePath = resourcesPath + "image" + File.separator + "test.gif";
		testSignedPdfFilePath = resourcesPath + "pdf" + File.separator + "anywriteSignedPDF.pdf";
		outPdfsFilePath = resourcesPath + "out" + File.separator;
	}

}
